<?php
/**
 * User Group Unassign API
 * Remove a user from a Contact Group
 *
 * @author Xavier VILAIN
 * @package MedicalStudy\MedicalCenter\Partner
 * @license #hive-license#
 * 
 */

use Hive\Ressource\Group;
$xview = Xview::instance();
$grouping = $xview->val('grouping');
$idusr = $xview->val('idusr');
if(!empty($grouping) && !empty($idusr)) {
	try {
		$group = new Group($grouping);
		$user = $group->findUsers($grouping.':'.$idusr);
		if($user->exists()) {
			$user->delete();
			Fox\Message::Success(Msg(Hive::BUNDLE,
						Hive::USER_HAS_BEEN_REMOVED_FROM_GROUP,
						User::fullName($idusr),$group->name));
		}
	} catch(Fox\Object\Exception\NotExist $e) {
		Fox\Message::Error($e);
	}
}
echo $xview->messages(true,true);